/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author lory
 */

import java.util.Iterator;
import java.util.ArrayList;

public class PdfIterator implements Iterator {
    
    ArrayList listaPdf;
    int position;
    
    public PdfIterator(ArrayList listaPdf) {
        this.listaPdf = listaPdf;
        position = 0;
    }
    
    public Object next() {
        Pdf pdf = (Pdf)listaPdf.get(position);
        position ++;
        return pdf;
    }
    
    public boolean hasNext() {
        if (position >= listaPdf.size() || listaPdf.get(position) == null)
            return false;
        else
            return true;
    }
    
    public void remove() {
        if (position <= 0)
            throw new IllegalStateException("Non esistono pdf da "
                    + "rimuovere\n");
        if (listaPdf.get(position-1) != null) {
            for (int i = position-1; i < listaPdf.size()-1; i++)
                listaPdf.get(i).equals(listaPdf.get(i++));
            listaPdf.get(listaPdf.size()-1).equals(null);
        }
    }
    
}
